/**
 *******************************************************************************
 * @file flash_driver.h
 * @author .ISS_AUTO (hudandan@issauto.com)
 * @version V0.0.0  2024-03-22
 *                  移植MCU-N32G45x,实现以下接口：
 *                  1. int32_t iss_flash_erase(uint32_t start_addr, uint32_t len);
 *                  2. int32_t iss_flash_write(uint32_t write_addr, void *data, uint32_t len);
 *                  3. int32_t iss_flash_read(uint32_t read_addr, void *data, uint32_t len);
 *
 * @brief This file for for flash interface.
 *
 * @copyright Copyright (c) 2024 ISSAUTO TECH Co., Ltd. All rights reserved.
 *
 *******************************************************************************
 */
#ifndef __ISS_FLASH_DRIVER_H
#define __ISS_FLASH_DRIVER_H

/* Includes ------------------------------------------------------------------*/
#include "main.h"

/* Exported types ------------------------------------------------------------*/

/* Exported constants --------------------------------------------------------*/
#if !defined(FLASH_MAX_SIZE)
    #define FLASH_MAX_SIZE             (0x00040000U)  //!< Flash Size: 0x00040000 (= 128*2KByte)
#endif

#define ISS_PAGE_SIZE               ((uint32_t)0x800U)          /* Page size = 2KByte */
#define ISS_FLASH_BASE_ADDR         ((uint32_t)0x08000000U)     /* IROM start: 0x8000000 */
#define ISS_FLASH_END_ADDR          (ISS_FLASH_BASE_ADDR + FLASH_MAX_SIZE)

/* Exported macro ------------------------------------------------------------*/
/* Exported functions --------------------------------------------------------*/
extern int32_t iss_flash_erase(uint32_t start_addr, uint32_t len);
extern int32_t iss_flash_write(uint32_t write_addr, void *data, uint32_t len);
extern int32_t iss_flash_read(uint32_t read_addr, void *data, uint32_t len);

#endif /* __ISS_FLASH_DRIVER_H */

/* END OF FILE ---------------------------------------------------------------*/
